#include "Input.h"

Input::Input()
{
   m_windowClosed = false;

   // Make sure all the keys are set to false.
   for (int i = 0; i < 323; i++)
   {
      m_keysHeld[i] = false;
   }
}

Input::~Input()
{
}



void Input::readInput()
{
	mouseUp=false;
   if (SDL_PollEvent(&m_event))
   {
       if(m_event.type == SDL_MOUSEBUTTONDOWN)
       {
        mouseDown = true;
        mouseButton = m_event.button.button;
		mouse_x = m_event.button.x;
		mouse_y = m_event.button.y;
       }
	   if(m_event.type == SDL_MOUSEMOTION)
	   {
		mouse_x = m_event.button.x;
		mouse_y = m_event.button.y;
	   }
       if(m_event.type == SDL_MOUSEBUTTONUP)
       {
		mouseUp = true;
        mouseDown = false;
		mouse_x = m_event.button.x;
		mouse_y = m_event.button.y;
       }
      if (m_event.type == SDL_QUIT)
      {
         m_windowClosed = true;
      }

      if (m_event.type == SDL_KEYDOWN)
      {
         m_keysHeld[m_event.key.keysym.sym] = true;
      }

      if (m_event.type == SDL_KEYUP)
      {
         m_keysHeld[m_event.key.keysym.sym] = false;
      }
   }
}
int Input::getMouseX()
{
    return mouse_x;
}
int Input::getMouseY()
{
    return mouse_y;
}
bool* Input::getInput()
{
   return m_keysHeld;
}

bool Input::windowClosed()
{
   return m_windowClosed;
}
